package com.mcxx.modules.filemanage.easypoi.handler;

import cn.afterturn.easypoi.handler.inter.IExcelDictHandler;
import com.mcxx.modules.base.service.read.DictionaryReadService;
import com.yinhai.ta404.module.dict.entity.TaDictPo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@Component
public class IExcelDictHandlerImpl implements IExcelDictHandler {

    @Autowired
    private DictionaryReadService testSysDictDetailMapper;

    private static DictionaryReadService sysDictDetailMapper;

    @PostConstruct
    public void init() {
        sysDictDetailMapper = this.testSysDictDetailMapper;
    }


    @Override
    public String toName(String dict, Object obj, String name, Object value) {
        if(value == null){
            return "无";
        }
        TaDictPo codeCache = sysDictDetailMapper.getCodeCache(dict, value.toString());
        return codeCache.getLabel();
    }


    @Override
    public String toValue(String dict, Object obj, String name, Object value) {
        return null;
    }
}
